package org.sanguine.tests.tenderpro.sax;

import org.sanguine.tests.tenderpro.sax.actions.Action;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * Author: Alexey Kuznetsov
 * Date: 20.02.14
 * SVN $Id$
 */
public class ProxyHandler implements InvocationHandler {

    Set<Action> handlers = new HashSet<>();

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        for (Action a : handlers) {
            method.invoke(a, args);
        }
        return null;
    }

    public ProxyHandler(List<Action> customHandlers) {
        handlers.addAll(customHandlers);
    }
}
